package com.mapper;

import com.javabean.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * @Author: 张波
 * @Time: 2025/8/27 10:42
 */
public interface ProductMapper {
	@Select("select * from project.product;")
	List<Product> selectAll();
	@Select("select * from project.product where product.productName like  concat('%',#{name},'%')")
//	@Select("select * from product where productName like concat('%',#{name},'%')")
	List<Product> selectLikeProductName(String name);

	@Select("select * from product where id = #{id}")
	Product selectById(int id);
	@Update("update product set productNum=#{productNum},productName=#{productName},cityName=#{cityName},departureTime=#{departureTime},productPrice=#{productPrice},productDesc=#{productDesc},productStatus=#{productStatus} where id=#{id};")
	int updateProduct(Product product);

	/// 添加产品
	@Insert("insert into product (productNum, productName, cityName, departureTime, productPrice, productDesc, productStatus) " +
			"values (#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus})")
	int insertProduct(Product product);
	@Delete("delete from product where id=#{id}")
	int deleteById(int id);

	/// 批量删除
	int deleteAll(List<Integer> ids);
}
